package com.zhuzi.dto.weixin;

import com.alibaba.fastjson2.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.collect.Lists;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.collections4.CollectionUtils;

import java.util.List;

/**
 * @author zhuzi
 * 2023/7/8 15:25
 * 微信文本消息,使用微信接受企业微信消息,只能显示文本,md格式显示不了,其他格式没尝试.
 * <a href="https://developer.work.weixin.qq.com/document/path/91770#%E6%96%87%E6%9C%AC%E7%B1%BB%E5%9E%8B">文本类型</a>
 */
@Data
@Accessors(chain = true)
public class TextMD {
    private String msgtype = "text";
    private TextItem text;

    @Data
    @Accessors(chain = true)
    public static class TextItem {

        private String content;
        @JsonProperty(value = "mentioned_list")
        @JSONField(name = "mentioned_list")
        private List<String> mentionedList;

        @JsonProperty(value = "mentioned_mobile_list")
        @JSONField(name = "mentioned_mobile_list")
        private List<String> mentionedMobileList;


        public TextItem all() {
            if (CollectionUtils.isEmpty(mentionedMobileList)) {
                mentionedMobileList = Lists.newArrayList();
            }
            mentionedMobileList.add("@all");
            return this;
        }
    }
}
